using System.ComponentModel.DataAnnotations.Schema;
using UniversalAdmin.Domain.Common;

namespace UniversalAdmin.Domain.Entities;

/// <summary>
/// 文章分类实体，对应 article_categories 表
/// </summary>
[Table("article_categories")]
public class ArticleCategory : AggregateRoot
{
  public string Name { get; private set; } = null!;
  public string Description { get; private set; } = string.Empty;
  public int? ParentId { get; private set; }
  public int Sort { get; private set; } = 0;
  public new bool IsActive { get; private set; } = true;

  private ArticleCategory() { }

  public static ArticleCategory Create(string name, string description, int? parentId = null, int sort = 0, bool isActive = true)
  {
    return new ArticleCategory
    {
      Name = name,
      Description = description,
      ParentId = parentId,
      Sort = sort,
      IsActive = isActive
    };
  }
  public void Update(string name, string description, int? parentId, int sort, bool isActive)
  {
    Name = name;
    Description = description;
    ParentId = parentId;
    Sort = sort;
    IsActive = isActive;
    UpdatedAt = DateTime.UtcNow;
  }
}